﻿<%@ page language="java" contentType="text/html; charset=UTF-8"   pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!-- 头部 -->	
<%@ include file="./space_head1.jsp"%>
<!-- 导航 -->	
<%@ include file="./space_head2.jsp"%>
		 
<script language="javascript">
	// 初始化点击分页按钮的方法
	onPageClickFunction = function(pageNo, event){
		location.href = '/sumer/collect/manage/' + pageNo + '/10';
	};

	 var statu = 0;
	
	function col_folder_del(id,cnt) {
	
		if(cnt>0){
			alert('收藏夹中有收藏，不能删除哦！');
		}else{
		if (window.confirm('确定要删除收藏夹吗？')) {
			$.post("/sumer/collect/delCollectFolder", {id: id}, function(result) {
				if(result.state == 1){
					alert('删除成功！');
					location.reload();
				}else {
					alert('删除失败！');
				}
			}, 'json');
		}
	}
	}
	 function col_folder_edit(id,folderName){
	
         var edit = document.getElementsByClassName('edit');
         var folders = document.getElementsByClassName('folderName');
         
         var folders_length = folders.length-1;
         
         var folders_value = new Array(folders_length);
          if(statu == 0){
        	  for(var i = 0; i <=folders_length; i++){
        		  folders_value[i] = folders[i].innerHTML;
                  if(folders_value[i]==folderName){
                	  edit[i].innerHTML= '保存';
                	  folders[i].innerHTML = '<input type="text" id="folders_input" value="'+folderName+'">';
                     
                  }
              }
                 statu = 1;
             }else{
                 edit.innerHTML= '编辑';
                 var folders_input = document.getElementById('folders_input');
                 folders_value = folders_input.value;
                     $.post("/sumer/collect/editCollectFolder", {id: id,folderName: folders_value}, function(result) {
         				if(result.state == 1){
         					alert('修改成功！');
         					location.reload();
         				}else {
         					alert('修改失败！');
         				}
         			}, 'json');
                 statu = 0;
             return false;
         }
         

	 } 
</script>
		 <!-- 主体内容   start -->
			
			<div class="zyt_body" style="height: auto;">
			
				<div class="user_body01" style="background-color: #FDFDFD;">
					<a href="drm_user_collect.htm#">
						<div class="home_colmanage">我的收藏</div>
					</a>
					
					<!-- 是当前所属人员 -->
					<c:if test="${isMeData}"> 
						<div style="width: 99%; height: 30px; margin-top: 20px;">
							<a href="#" onClick="col_add()">
								<div class="retext02 home_coladd00"
									style="float: right; font-size: 12px; right: 20px;">新建文件夹</div>
							</a>
						</div>
					</c:if>
					
					<div class="zyzx_more_div" style="margin-top: 20px;">
						<div style="float: left; width: 220px; height: 150px;">
							<div class="retext02 home_coladd">收藏夹管理</div>
						</div>
						<div class="zyzx_more_left" style="float: right; margin-right: 50px;">
							<div class="kczx_son_divbodytbl">
								<div id="tab1" class="user_tab1" style="height: 530px; left: 5px;">
									<table class="collect_left_tr" cellspacing="0" cellpadding="0"
										style="text-align: center;">
										<tr
											style="background-color: #EEE; height: 40px; text-align: center; border: 1px solid #DDD;">
											<td width="200px" style="text-align: center;">收藏夹名称</td>
											<td width="100px">内容数量</td>
											<td width="100px">创建时间</td>
											<td width="80px">操作</td>
										</tr>
										
										<c:forEach items="${pageData.data}" var="folder">
										<tr style="border-bottom: 1px solid #DDD;">
											<td class ="folderName" width="90px">${folder.folderName}</td>
											<td width="90px">${folder.cnt}</td>
											<td>${folder.createDate}</td>
											<td><a class="edit" href="#" style="color: #3381a7" onClick="col_folder_edit('${folder.id}','${folder.folderName}');" >编辑</a>
												<a href="#" style="color: #3381a7" onClick="col_folder_del('${folder.id}',${folder.cnt});">删除</a></td>
											</tr>	
										</c:forEach>
										
									</table>
									<br>
							<%@ include file="../paging_form.jsp"%>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			
	<!-- 主体内容 - end -->		
		 
		
	<!--新建收藏夹     编辑 新建 都是用这个 div   -->
	 	<%@ include file="collect_mod.jsp"%>
	<!--end新建收藏夹-->
		 
 <!--  结尾 -->
 <%@ include file="../all_buttom.jsp"%>
 </body>
</html>